<!--
 * @author: sanbao
 * @Date: 2022-07-23 10:23:03
-->
<style lang='scss' scoped>
</style>

<template>
  <div class="rights">
    <my-table
      :tableData="tableData"
      :tablelist="tablelist"
      @handleSizeChange="handleSizeChange"
      @handleCurrentChange="handleCurrentChange"
      :pager="pager"
    >
    </my-table>
  </div>
</template>

<script lang='ts'>
import {
  defineComponent,
  ref,
  reactive,
  toRefs,
  computed,
  onMounted,
} from "vue";
import RightsModel from "@/api/rights";
import { RightsData } from "@/type/rights";
import MyTable from "@/components/child/MyTable.vue";
import { ElMessage } from "element-plus";
export default defineComponent({
  components: { MyTable },
  setup() {
    onMounted(() => {
      getrightslist();
    });
    const data = reactive(new RightsData());
    // 数据
    const getrightslist = async () => {
      const response = await RightsModel.getrightslist();
      if (response.data.meta.status == "200") {
        data.tableData = response.data.data;
      }
    };
    // 页
    const handleSizeChange = (size: number) => {
      data.pager.pageSize = size;
      getrightslist().then(() => ElMessage.success("搜索成功"));
    };
    // 条
    const handleCurrentChange = (page: number) => {
      data.pager.currentPage = page;
      getrightslist().then(() => ElMessage.success("搜索成功"));
    };
    const handeltablebutton = () => {};
    return {
      ...toRefs(data),
      handleSizeChange,
      handleCurrentChange,
    };
  },
});
</script>
